package org.example.struct.array;

/**
 * @author liyishan
 * @date 2024/7/5 09:25
 * @apiNote
 */

public class Test03033ModifiedMatrix {

    public int[][] modifiedMatrix(int[][] matrix) {
        int m = matrix.length;
        int n = matrix[0].length;
        int[][] answer = new int[m][n];
        for(int i= 0; i < m; i++){
            for(int j = 0; j <n; j++){
                if(matrix[i][j] != -1){
                    answer[i][j] = matrix[i][j];
                }else{
                    int max = -1;
                    for(int k = 0;k<m;k++){
                        max = Math.max(max,matrix[k][j]);
                    }
                    answer[i][j] = max;
                }
            }
        }
        return answer;
    }
}
